<template>
  <div class="page">
    <div class="vedio">
      <div v-if="post_data.video_type == 1">
        <video
          :src="video"
          :custom-cache="false"
          class="video-css"
          :loop="loop"
        ></video>
      </div>
      <div v-else>
        <txv-video :vid="post_data.video_vid" playerid="txv1"></txv-video>
      </div>
    </div>
    <div class="oth">
      <wxParse :content="article" />
    </div>
  </div>
</template>

<script>
import wxParse from "mpvue-wxparse";

export default {
  components: {
    wxParse,
  },
  data() {
    return {
      server_url: "https://jinrigaoling.com/",
      // server_url:'http://cmf5pro.cn/',
      post_data: {},
      user: {},
      video: {},
      loop: true,
      article: "<div >加载中。。。</div>",
    };
  },
  mounted() {
    console.log(this.$root.$mp.query);
    var id = this.$root.$mp.query.aid;
    wx.request({
      url: this.server_url + "api/portal/articles/" + id,
      success: (res) => {
        this.article =
          '<div style="width:95%;margin:0 auto;">' +
          res.data.data.post_content +
          "</div>";
        this.post_data = res.data.data;
        this.user = res.data.data.user;
        this.video = res.data.data.more.video;
        wx.setNavigationBarTitle({
          title: res.data.data.post_title,
        });
        // console.log(this.article);
      },
    });
    console.log("post:", this.post_data);
  },
  onShareAppMessage() {
    return {
      title: this.post_data.post_title,
    };
  },
};
</script>

<style scoped>
@import url("~mpvue-wxparse/src/wxParse.css");
.page {
  background: #eeeeee;
}
.vedio {
  width: 100%;
  /* height: 300px; */
  /* border: 1px solid red; */
  position: sticky;
  top: 0;
}
.video-css {
  width: 100%;
}
.oth {
  padding: 4rpx 0;
  background: #fff;
  margin-top: 4rpx;
}
</style>